/**
 * 
 */
package org.drl.xmpp.storage;

import org.drl.xmpp.storage.table.AccountTable;
import org.drl.xmpp.storage.table.ContactTable;
import org.drl.xmpp.storage.table.MessageTable;
import org.drl.xmpp.storage.table.SessionTable;
import org.drl.xmpp.storage.table.VCardTable;

import android.app.Application;

/**
 * 数据库所依赖的 Application,开发者可以将本来功能集成到自己项目的Application中.
 * @author hljdrl@gmail.com
 * 
 */
public class DBApplication extends Application {

	private static DBApplication instance;


	public DBApplication() {
		instance = this;
		//必须先注册表,否则无法创建所有的表
		DataBaseManager.getInstance().addTable(AccountTable.getInstance());
		DataBaseManager.getInstance().addTable(ContactTable.getInstance());
		DataBaseManager.getInstance().addTable(MessageTable.getInstance());
		DataBaseManager.getInstance().addTable(SessionTable.getInstance());
		DataBaseManager.getInstance().addTable(VCardTable.getInstance());
		//所有的加载数据必须在 注册完以后的数据库表后面-加载.
		
	}
	public static DBApplication getInstance() {
		if (instance == null)
			throw new IllegalStateException();
		return instance;
	}

}
